package logic

import (
	"context"
	"yuekaoHouse/house_srv/house"

	"yuekaoHouse/api/internal/svc"
	"yuekaoHouse/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseListAddressLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHouseListAddressLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseListAddressLogic {
	return &HouseListAddressLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HouseListAddressLogic) HouseListAddress(req *types.HouseListAddressRequest) (resp *types.RegMsgResponse, err error) {
	// todo: 房源地区查询

	_, err = l.svcCtx.HouseSrv.HouseListAddress(l.ctx, &house.HouseListAddressRequest{Address: req.Address})
	if err != nil {
		return &types.RegMsgResponse{
			Cre:  -1,
			Mag:  "服务器错误",
			Data: nil,
		}, err
	}

	return &types.RegMsgResponse{
		Cre:  0,
		Mag:  "查询成功",
		Data: nil,
	}, err
}
